<div class="row">
    <div class="col-xl-12">
        <!-- BEGIN card -->
        <div class="card m-b-15">
            <!-- BEGIN card-header -->
            <div class="card-header card-header-inverse">
                <h4 class="card-header-title">设置密码</h4>
            </div>
            <!-- END card-header -->
            <!-- BEGIN card-body -->
            <div class="card-body">
                <!-- BEGIN nav-tabs -->
                <ul class="nav nav-tabs" id="nav-tabs">
                    <li class="nav-item"><a href="#loginpassword" class="nav-link show active" role="tab" data-toggle="tab">登录密码</a></li>
<!--                    <li class="nav-item"><a href="#userpassword" class="nav-link show" role="tab" data-toggle="tab">交易密码</a></li>-->
                </ul>
                <!-- END nav-tabs -->
                <!-- BEGIN tab-content -->
                <div class="tab-content tab-content-bordered">
                    <!-- BEGIN tab-pane -->
                    <div class="col-md-2">
                        <div class="tab-content">
                            <div class="tab-pane active" id="loginpassword">
                                <form class="pageform" method="post" action="<?= \yii\helpers\Url::to(['/masters/modify-password'])?>" data-validator-option="{theme: 'yellow_top',timely:2, focusCleanup:true}">
                                    <div class="row">
                                        <div class="col-md-12">
                                            <div class="form-group label-floating is-empty is-info">
                                                <label class="control-label">原始登录密码<small class="text-danger">*</small></label>
                                                <input type="password" name="ologinpwd" class="form-control form-control-sm" data-rule="原始登录密码:required;length(6~32)" value="">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-12">
                                            <div class="form-group label-floating is-empty is-info">
                                                <label class="control-label">重置登录密码<small class="text-danger">*</small></label>
                                                <input type="password" name="nloginpwd" class="form-control form-control-sm" data-rule="重置登录密码:required;match[neq, ologinpwd];length(6~32)" value="">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-12">
                                            <div class="form-group label-floating is-empty is-info">
                                                <label class="control-label">确认登录密码<small class="text-danger">*</small></label>
                                                <input type="password" name="rnloginpwd" class="form-control form-control-sm" data-rule="确认登录密码:required;match(nloginpwd);length(6~32)" value="">
                                            </div>
                                        </div>
                                    </div>
                                    <input type="hidden" name="passType" value="0" />
                                    <button type="submit" class="btn btn-primary btn-sm m-b-5 m-r-3">确认提交</button>
                                    <div class="clearfix"></div>
                                </form>
                            </div>
                            <div class="tab-pane" id="userpassword">
                                <form class="pageform" method="post" action="<?= \yii\helpers\Url::to(['/masters/modify-password'])?>" data-validator-option="{theme: 'yellow_top',timely:2, focusCleanup:true}">
                                    <div class="row">
                                        <div class="col-md-12">
                                            <div class="form-group label-floating is-empty is-info">
                                                <label class="control-label">原始交易密码<small class="text-danger">*</small></label>
                                                <input type="password" name="ouserpwd" class="form-control form-control-sm" data-rule="原始交易密码:required;length(6~32)" value="">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-12">
                                            <div class="form-group label-floating is-empty is-info">
                                                <label class="control-label">重置交易密码<small class="text-danger">*</small></label>
                                                <input type="password" name="nuserpwd" class="form-control form-control-sm" data-rule="重置交易密码:required;match[neq, ouserpwd];length(6~32)" value="">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-md-12">
                                            <div class="form-group label-floating is-empty is-info">
                                                <label class="control-label">确认交易密码<small class="text-danger">*</small></label>
                                                <input type="password" name="rnuserpwd" class="form-control form-control-sm" data-rule="确认交易密码:required;match(nuserpwd);length(6~32)" value="">
                                            </div>
                                        </div>
                                    </div>
                                    <input type="hidden" name="passType" value="1" />
                                    <button type="submit" class="btn btn-warning btn-sm m-b-5 m-r-3">确认提交</button>
                                    <div class="clearfix"></div>
                                </form>
                            </div>
                        </div>
                    </div>
                    <!-- END tab-pane -->
                </div>
                <!-- END tab-content -->
            </div>
            <!-- END card-body -->
        </div>
        <!-- END panel -->
    </div>
</div>
<script type="text/javascript">
    $(function () {
        $(".pageform").each(function () {
            $(this).on('validation', function (e, current) {
                var field = $(current.element).closest('div');
                if (current.isValid) {
                    if (field.hasClass('has-error')) field.removeClass('has-error');
                    if (field.find('.form-control-feedback').length === 0) field.append('<span class="material-icons form-control-feedback">done</span>');
                    else field.find('.form-control-feedback').text('done');
                    field.addClass('has-success');
                } else {
                    if (field.hasClass('has-success')) field.removeClass('has-success');
                    if (field.find('.form-control-feedback').length === 0) field.append('<span class="material-icons form-control-feedback">clear</span>');
                    else field.find('.form-control-feedback').text('clear');
                    field.addClass('has-error');
                }
            }).on('valid.form', function (e, form) {
                $(this).ajaxSubmit({
                    restForm: true,
                    clearForm: true,
                    beforeSubmit: function () {
                        $(form).find('.has-success').removeClass('has-success');
                        $(form).find('.form-control-feedback').remove('.form-control-feedback');
                    },
                    success: function (d) {
                        if (d.statusCode === 200) {
                            swal({
                                type: "success",
                                title: '操作成功！',
                                text: d.message,
                                buttonsStyling: false,
                                confirmButtonText: "马上登录！",
                                confirmButtonClass: "btn btn-info",
                                allowOutsideClick: false,
                                timer: 3000
                            }).then(function () {
                                window.location.href = "../site/logout";
                            }, function (dismiss) {
                                if (dismiss === 'timer') {
                                    window.location.href = "../site/logout";
                                }
                            });
                            return false;
                        }
                        swal('操作失败！', d.message, 'error');
                    }
                });
            });
        });
    });
</script>